package com.example;

import com.example.service.OrderService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class MainApplication {
    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
        OrderService orderService = context.getBean(OrderService.class);

        try {
            orderService.add("手机", 2);
        } catch (Exception e) {
            System.out.println("操作失败: " + e.getMessage());
        }

        try {
            orderService.delete("电脑");
        } catch (Exception e) {
            System.out.println("操作失败: " + e.getMessage());
        }

        try {
            int count = orderService.find("平板");
            System.out.println("查询结果: " + count);
        } catch (Exception e) {
            System.out.println("操作失败: " + e.getMessage());
        }
    }
}